import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator;

import java.io.IOException;

public class HdfsExample {

    public static void main(String[] args) throws IOException {
        Configuration configuration = new Configuration();
        FileSystem fs = FileSystem.get(configuration);
        RemoteIterator<LocatedFileStatus> iterator = fs.listFiles(new Path("/test_work"), false);
        while(iterator.hasNext()) {
            LocatedFileStatus locatedFileStatus = iterator.next();
            System.out.println(locatedFileStatus.getPath());
        }
    }

}
